// // --------------------------------------------------------------------------------------------------------------------
// // <copyright file="TermsAndConditionsForm.cs" company="Collaboris">
// //   Copyright Collaboris
// // </copyright>
// // <summary>
// //   
// // </summary>
// // --------------------------------------------------------------------------------------------------------------------

namespace DocRead.Selenium.Tests.DocRead.ControlObjects
{
    #region

    using Collaboris.ShareTest.Core;
    using Collaboris.ShareTest.SharePoint2010.ControlObjects;

    using OpenQA.Selenium;
    using OpenQA.Selenium.Remote;

    #endregion

    public class MessagesForm : SPTModelBase
    {
        #region Constants and Fields

        public static string CtrlCancelButton = "ctl00_PlaceHolderMain_ctl00_BtnCancel";

        public static string CtrlOkButton = "ctl00_PlaceHolderMain_ctl00_RptControls_SaveButton";

        public static string CtrlCompletedReadershipTitleId = "ctl00_PlaceHolderMain_CompletedReadershipSection_CompletedReadershipTitle";

        public static string CtrlCompletedReadershipTitleErrorId = "ctl00_PlaceHolderMain_CompletedReadershipSection_CompletedReadershipTitleValidator";

        public static string CtrlCompletedReadershipId = "ctl00_PlaceHolderMain_CompletedReadershipSection_CompletedReadershipTextBox";

        public static string CtrlCompletedReadershipErrorId = "ctl00_PlaceHolderMain_CompletedReadershipSection_CompletedReadershipTextBoxValidator";

        public static string CtrlDeletedReadershipTitleId = "ctl00_PlaceHolderMain_DeletedReadershipSection_DeletedReadershipTitle";

        public static string CtrlDeletedReadershipTitleErrorId = "ctl00_PlaceHolderMain_DeletedReadershipSection_DeletedReadershipTitleValidator";

        public static string CtrlDeletedReadershipId = "ctl00_PlaceHolderMain_DeletedReadershipSection_DeletedReadershipTextBox";

        public static string CtrlDeletedReadershipErrorId = "ctl00_PlaceHolderMain_DeletedReadershipSection_DeletedReadershipTextBoxValidator";

        public static string CtrlReadershipNotRequiredTitleId = "ctl00_PlaceHolderMain_NotRequiredReadershipSection_NotRequiredReadershipTitle";

        public static string CtrlReadershipNotRequiredTitleErrorId = "ctl00_PlaceHolderMain_NotRequiredReadershipSection_NotRequiredReadershipTitleValidator";

        public static string CtrlReadershipNotRequiredId = "ctl00_PlaceHolderMain_NotRequiredReadershipSection_NotRequiredReadershipTextBox";

        public static string CtrlReadershipNotRequiredErrorId = "ctl00_PlaceHolderMain_NotRequiredReadershipSection_NotRequiredReadershipTextBoxValidator";

        public static string CtrlOverdueReadershipTitleId = "ctl00_PlaceHolderMain_OverdueReadershipSection_OverdueReadershipTitle";

        public static string CtrlOverdueReadershipTitleErrorId = "ctl00_PlaceHolderMain_OverdueReadershipSection_OverdueReadershipTitleValidator";

        public static string CtrlOverdueReadershipId = "ctl00_PlaceHolderMain_OverdueReadershipSection_OverdueReadershipTextBox";

        public static string CtrlOverdueReadershipErrorId = "ctl00_PlaceHolderMain_OverdueReadershipSection_OverdueReadershipTextBoxValidator";

        public static string CtrlRecommendedReadershipTitleId = "ctl00_PlaceHolderMain_RecommendedReadershipSection_RecommendedReadershipTitle";

        public static string CtrlRecommendedReadershipTitleErrorId = "ctl00_PlaceHolderMain_RecommendedReadershipSection_RecommendedReadershipTitleValidator";

        public static string CtrlRecommendedReadershipId = "ctl00_PlaceHolderMain_RecommendedReadershipSection_RecommendedReadershipTextBox";

        public static string CtrlRecommendedReadershipErrorId = "ctl00_PlaceHolderMain_RecommendedReadershipSection_RecommendedReadershipTextBoxValidator";

        public static string CtrlRequiredReadershipTitleId = "ctl00_PlaceHolderMain_RequiredReadershipSection_RequiredReadershipTitle";

        public static string CtrlRequiredReadershipTitleErrorId = "ctl00_PlaceHolderMain_RequiredReadershipSection_RequiredReadershipTitleValidator";

        public static string CtrlRequiredReadershipId = "ctl00_PlaceHolderMain_RequiredReadershipSection_RequiredReadershipTextBox";

        public static string CtrlRequiredReadershipErrorId = "ctl00_PlaceHolderMain_RequiredReadershipSection_RequiredReadershipTextBoxValidator";

        public static string CtrlPositiveReceiptTitleId = "ctl00_PlaceHolderMain_ReceiptMessageSection_PositiveReceiptMessageTextBox";

        public static string CtrlPositiveReceiptTitleErrorId = "ctl00_PlaceHolderMain_ReceiptMessageSection_PositiveReceiptMessageTextBoxValidator";

        public static string CtrlNegativeReceiptTitleId = "ctl00_PlaceHolderMain_ReceiptMessageSection_NegativeReceiptMessageTextBox";

        public static string CtrlNegativeReceiptTitleErrorId = "ctl00_PlaceHolderMain_ReceiptMessageSection_NegativeReceiptMessageTextBoxValidator";

        #endregion

        #region Constructors and Destructors

        public MessagesForm(RemoteWebDriver driver)
            : base(driver)
        {
        }

        #endregion

        #region Public Properties

        #region Common Elements
        public IWebElement CancelButton
        {
            get
            {
                return this.WebDriver.FindElementById(CtrlCancelButton);
            }
        }

        public IWebElement OkButton
        {
            get
            {
                return this.WebDriver.FindElementById(CtrlOkButton);
            }
        }

        public string TopLevelError { get; set; }

        public IWebElement TopLevelErrorElement
        {
            get
            {
                return this.WebDriver.IsElementPresent(By.XPath(Locators.XpathTopLevelErrorIdentifier))
                           ? this.WebDriver.FindElementByXPath(Locators.XpathTopLevelErrorIdentifier)
                           : null;
            }
        }

        #endregion

        // ** end common **//

        #region CompletedReadership

        // ** TITLES **/

        public string CompletedReadershipTitle { get; set; }

        /// <summary>
        /// CompletedReadershipTitle Element
        /// </summary>
        public IWebElement CompletedReadershipTitleElement
        {
            get
            {
                return this.WebDriver.FindElementById(CtrlCompletedReadershipTitleId);
            }
        }

        /// <summary>
        /// Error Message for CompletedReadershipTitle as string
        /// </summary>
        public string CompletedReadershipTitleErrorMessage { get; set; }

        /// <summary>
        /// Error Message for CompletedReadershipTitle as Element
        /// </summary>
        public IWebElement CompletedReadershipTitleElementErrorMessageElement
        {
            get
            {
                if (this.WebDriver.IsElementPresent(By.Id(CtrlCompletedReadershipTitleErrorId)))
                {
                    return this.WebDriver.FindElementById(CtrlCompletedReadershipTitleErrorId);
                }
                return null;
            }
        }

        // ** MESSAGE **/

        public string CompletedReadership { get; set; }

        /// <summary>
        /// CompletedReadership Element
        /// </summary>
        public IWebElement CompletedReadershipElement
        {
            get
            {
                return this.WebDriver.FindElementById(CtrlCompletedReadershipId);
            }
        }

        /// <summary>
        /// Error Message for CompletedReadership as string
        /// </summary>
        public string CompletedReadershipErrorMessage { get; set; }

        /// <summary>
        /// Error Message for CompletedReadership as Element
        /// </summary>
        public IWebElement CompletedReadershipElementErrorMessageElement
        {
            get
            {
                if (this.WebDriver.IsElementPresent(By.Id(CtrlCompletedReadershipErrorId)))
                {
                    return this.WebDriver.FindElementById(CtrlCompletedReadershipErrorId);
                }
                return null;
            }
        }



        #endregion

        #region DeletedReadership

        // ** TITLES **/

        public string DeletedReadershipTitle { get; set; }

        /// <summary>
        /// DeletedReadershipTitle Element
        /// </summary>
        public IWebElement DeletedReadershipTitleElement
        {
            get
            {
                return this.WebDriver.FindElementById(CtrlDeletedReadershipTitleId);
            }
        }

        /// <summary>
        /// Error Message for DeletedReadershipTitle as string
        /// </summary>
        public string DeletedReadershipTitleErrorMessage { get; set; }

        /// <summary>
        /// Error Message for DeletedReadershipTitle as Element
        /// </summary>
        public IWebElement DeletedReadershipTitleElementErrorMessageElement
        {
            get
            {
                if (this.WebDriver.IsElementPresent(By.Id(CtrlDeletedReadershipTitleErrorId)))
                {
                    return this.WebDriver.FindElementById(CtrlDeletedReadershipTitleErrorId);
                }
                return null;
            }
        }

        // ** MESSAGE **/

        public string DeletedReadership { get; set; }

        /// <summary>
        /// DeletedReadership Element
        /// </summary>
        public IWebElement DeletedReadershipElement
        {
            get
            {
                return this.WebDriver.FindElementById(CtrlDeletedReadershipId);
            }
        }

        /// <summary>
        /// Error Message for DeletedReadership as string
        /// </summary>
        public string DeletedReadershipErrorMessage { get; set; }

        /// <summary>
        /// Error Message for DeletedReadership as Element
        /// </summary>
        public IWebElement DeletedReadershipElementErrorMessageElement
        {
            get
            {
                if (this.WebDriver.IsElementPresent(By.Id(CtrlDeletedReadershipErrorId)))
                {
                    return this.WebDriver.FindElementById(CtrlDeletedReadershipErrorId);
                }
                return null;
            }
        }



        #endregion

        #region ReadershipNotRequired

        // ** TITLES **/

        public string ReadershipNotRequiredTitle { get; set; }

        /// <summary>
        /// ReadershipNotRequiredTitle Element
        /// </summary>
        public IWebElement ReadershipNotRequiredTitleElement
        {
            get
            {
                return this.WebDriver.FindElementById(CtrlReadershipNotRequiredTitleId);
            }
        }

        /// <summary>
        /// Error Message for ReadershipNotRequiredTitle as string
        /// </summary>
        public string ReadershipNotRequiredTitleErrorMessage { get; set; }

        /// <summary>
        /// Error Message for ReadershipNotRequiredTitle as Element
        /// </summary>
        public IWebElement ReadershipNotRequiredTitleElementErrorMessageElement
        {
            get
            {
                if (this.WebDriver.IsElementPresent(By.Id(CtrlReadershipNotRequiredTitleErrorId)))
                {
                    return this.WebDriver.FindElementById(CtrlReadershipNotRequiredTitleErrorId);
                }
                return null;
            }
        }

        // ** MESSAGE **/

        public string ReadershipNotRequired { get; set; }

        /// <summary>
        /// ReadershipNotRequired Element
        /// </summary>
        public IWebElement ReadershipNotRequiredElement
        {
            get
            {
                return this.WebDriver.FindElementById(CtrlReadershipNotRequiredId);
            }
        }

        /// <summary>
        /// Error Message for ReadershipNotRequired as string
        /// </summary>
        public string ReadershipNotRequiredErrorMessage { get; set; }

        /// <summary>
        /// Error Message for ReadershipNotRequired as Element
        /// </summary>
        public IWebElement ReadershipNotRequiredElementErrorMessageElement
        {
            get
            {
                if (this.WebDriver.IsElementPresent(By.Id(CtrlReadershipNotRequiredErrorId)))
                {
                    return this.WebDriver.FindElementById(CtrlReadershipNotRequiredErrorId);
                }
                return null;
            }
        }



        #endregion

        #region OverdueReadership

        // ** TITLES **/

        public string OverdueReadershipTitle { get; set; }

        /// <summary>
        /// OverdueReadershipTitle Element
        /// </summary>
        public IWebElement OverdueReadershipTitleElement
        {
            get
            {
                return this.WebDriver.FindElementById(CtrlOverdueReadershipTitleId);
            }
        }

        /// <summary>
        /// Error Message for OverdueReadershipTitle as string
        /// </summary>
        public string OverdueReadershipTitleErrorMessage { get; set; }

        /// <summary>
        /// Error Message for OverdueReadershipTitle as Element
        /// </summary>
        public IWebElement OverdueReadershipTitleElementErrorMessageElement
        {
            get
            {
                if (this.WebDriver.IsElementPresent(By.Id(CtrlOverdueReadershipTitleErrorId)))
                {
                    return this.WebDriver.FindElementById(CtrlOverdueReadershipTitleErrorId);
                }
                return null;
            }
        }

        // ** MESSAGE **/

        public string OverdueReadership { get; set; }

        /// <summary>
        /// OverdueReadership Element
        /// </summary>
        public IWebElement OverdueReadershipElement
        {
            get
            {
                return this.WebDriver.FindElementById(CtrlOverdueReadershipId);
            }
        }

        /// <summary>
        /// Error Message for OverdueReadership as string
        /// </summary>
        public string OverdueReadershipErrorMessage { get; set; }

        /// <summary>
        /// Error Message for OverdueReadership as Element
        /// </summary>
        public IWebElement OverdueReadershipElementErrorMessageElement
        {
            get
            {
                if (this.WebDriver.IsElementPresent(By.Id(CtrlOverdueReadershipErrorId)))
                {
                    return this.WebDriver.FindElementById(CtrlOverdueReadershipErrorId);
                }
                return null;
            }
        }



        #endregion

        #region RecommendedReadership

        // ** TITLES **/

        public string RecommendedReadershipTitle { get; set; }

        /// <summary>
        /// RecommendedReadershipTitle Element
        /// </summary>
        public IWebElement RecommendedReadershipTitleElement
        {
            get
            {
                return this.WebDriver.FindElementById(CtrlRecommendedReadershipTitleId);
            }
        }

        /// <summary>
        /// Error Message for RecommendedReadershipTitle as string
        /// </summary>
        public string RecommendedReadershipTitleErrorMessage { get; set; }

        /// <summary>
        /// Error Message for RecommendedReadershipTitle as Element
        /// </summary>
        public IWebElement RecommendedReadershipTitleElementErrorMessageElement
        {
            get
            {
                if (this.WebDriver.IsElementPresent(By.Id(CtrlRecommendedReadershipTitleErrorId)))
                {
                    return this.WebDriver.FindElementById(CtrlRecommendedReadershipTitleErrorId);
                }
                return null;
            }
        }

        // ** MESSAGE **/

        public string RecommendedReadership { get; set; }

        /// <summary>
        /// RecommendedReadership Element
        /// </summary>
        public IWebElement RecommendedReadershipElement
        {
            get
            {
                return this.WebDriver.FindElementById(CtrlRecommendedReadershipId);
            }
        }

        /// <summary>
        /// Error Message for RecommendedReadership as string
        /// </summary>
        public string RecommendedReadershipErrorMessage { get; set; }

        /// <summary>
        /// Error Message for RecommendedReadership as Element
        /// </summary>
        public IWebElement RecommendedReadershipElementErrorMessageElement
        {
            get
            {
                if (this.WebDriver.IsElementPresent(By.Id(CtrlRecommendedReadershipErrorId)))
                {
                    return this.WebDriver.FindElementById(CtrlRecommendedReadershipErrorId);
                }
                return null;
            }
        }



        #endregion

        #region RequiredReadership

        // ** TITLES **/

        public string RequiredReadershipTitle { get; set; }

        /// <summary>
        /// RequiredReadershipTitle Element
        /// </summary>
        public IWebElement RequiredReadershipTitleElement
        {
            get
            {
                return this.WebDriver.FindElementById(CtrlRequiredReadershipTitleId);
            }
        }

        /// <summary>
        /// Error Message for RequiredReadershipTitle as string
        /// </summary>
        public string RequiredReadershipTitleErrorMessage { get; set; }

        /// <summary>
        /// Error Message for RequiredReadershipTitle as Element
        /// </summary>
        public IWebElement RequiredReadershipTitleElementErrorMessageElement
        {
            get
            {
                if (this.WebDriver.IsElementPresent(By.Id(CtrlRequiredReadershipTitleErrorId)))
                {
                    return this.WebDriver.FindElementById(CtrlRequiredReadershipTitleErrorId);
                }
                return null;
            }
        }

        // ** MESSAGE **/

        public string RequiredReadership { get; set; }

        /// <summary>
        /// RequiredReadership Element
        /// </summary>
        public IWebElement RequiredReadershipElement
        {
            get
            {
                return this.WebDriver.FindElementById(CtrlRequiredReadershipId);
            }
        }

        /// <summary>
        /// Error Message for RequiredReadership as string
        /// </summary>
        public string RequiredReadershipErrorMessage { get; set; }

        /// <summary>
        /// Error Message for RequiredReadership as Element
        /// </summary>
        public IWebElement RequiredReadershipElementErrorMessageElement
        {
            get
            {
                if (this.WebDriver.IsElementPresent(By.Id(CtrlRequiredReadershipErrorId)))
                {
                    return this.WebDriver.FindElementById(CtrlRequiredReadershipErrorId);
                }
                return null;
            }
        }



        #endregion

        #region PositiveReceipt



        public string PositiveReceipt { get; set; }

        /// <summary>
        /// PositiveReceipt Element
        /// </summary>
        public IWebElement PositiveReceiptElement
        {
            get
            {
                return this.WebDriver.FindElementById(CtrlPositiveReceiptTitleId);
            }
        }

        /// <summary>
        /// Error Message for PositiveReceipt as string
        /// </summary>
        public string PositiveReceiptErrorMessage { get; set; }

        /// <summary>
        /// Error Message for PositiveReceipt as Element
        /// </summary>
        public IWebElement PositiveReceiptTitleElementErrorMessageElement
        {
            get
            {
                if (this.WebDriver.IsElementPresent(By.Id(CtrlPositiveReceiptTitleErrorId)))
                {
                    return this.WebDriver.FindElementById(CtrlPositiveReceiptTitleErrorId);
                }
                return null;
            }
        }


        #endregion

        #region NegativeReceipt



        public string NegativeReceipt { get; set; }

        /// <summary>
        /// NegativeReceipt Element
        /// </summary>
        public IWebElement NegativeReceiptElement
        {
            get
            {
                return this.WebDriver.FindElementById(CtrlNegativeReceiptTitleId);
            }
        }

        /// <summary>
        /// Error Message for NegativeReceipt as string
        /// </summary>
        public string NegativeReceiptErrorMessage { get; set; }

        /// <summary>
        /// Error Message for NegativeReceipt as Element
        /// </summary>
        public IWebElement NegativeReceiptTitleElementErrorMessageElement
        {
            get
            {
                if (this.WebDriver.IsElementPresent(By.Id(CtrlNegativeReceiptTitleErrorId)))
                {
                    return this.WebDriver.FindElementById(CtrlNegativeReceiptTitleErrorId);
                }
                return null;
            }
        }


        #endregion

        #endregion

        #region Public Methods

        public void RefreshForm()
        {
            // titles
            this.CompletedReadershipTitle = this.CompletedReadershipTitleElement.GetAttribute("value");
            this.DeletedReadershipTitle = this.DeletedReadershipTitleElement.GetAttribute("value");
            this.ReadershipNotRequiredTitle = this.ReadershipNotRequiredTitleElement.GetAttribute("value");
            this.OverdueReadershipTitle = this.OverdueReadershipTitleElement.GetAttribute("value");
            this.RecommendedReadershipTitle = this.RecommendedReadershipTitleElement.GetAttribute("value");
            this.RequiredReadershipTitle = this.RequiredReadershipTitleElement.GetAttribute("value");

            // form text values
            this.CompletedReadership = this.CompletedReadershipElement.GetAttribute("value");
            this.DeletedReadership = this.DeletedReadershipElement.GetAttribute("value");
            this.ReadershipNotRequired = this.ReadershipNotRequiredElement.GetAttribute("value");
            this.OverdueReadership = this.OverdueReadershipElement.GetAttribute("value");
            this.RecommendedReadership = this.RecommendedReadershipElement.GetAttribute("value");
            this.RequiredReadership = this.RequiredReadershipElement.GetAttribute("value");

            this.PositiveReceipt = this.PositiveReceiptElement.GetAttribute("value");
            this.NegativeReceipt = this.NegativeReceiptElement.GetAttribute("value");
            
            // errors
            if (this.TopLevelErrorElement != null)
            {
                this.TopLevelError = this.TopLevelErrorElement.Text;
            }

            // ** Title Errors

            if (this.CompletedReadershipTitleElementErrorMessageElement != null)
            {
                this.CompletedReadershipTitleErrorMessage = this.CompletedReadershipTitleElementErrorMessageElement.Text;
            }

            if (this.DeletedReadershipTitleElementErrorMessageElement!= null)
            {
                this.DeletedReadershipTitleErrorMessage = this.DeletedReadershipTitleElementErrorMessageElement.Text;
            }

            if (this.ReadershipNotRequiredTitleElementErrorMessageElement != null)
            {
                this.ReadershipNotRequiredTitleErrorMessage = this.ReadershipNotRequiredTitleElementErrorMessageElement.Text;
            }

            if (this.OverdueReadershipTitleElementErrorMessageElement != null)
            {
                this.OverdueReadershipTitleErrorMessage = this.OverdueReadershipTitleElementErrorMessageElement.Text;
            }

            if (this.RequiredReadershipTitleElementErrorMessageElement != null)
            {
                this.RequiredReadershipTitleErrorMessage = this.RequiredReadershipTitleElementErrorMessageElement.Text;
            }

            if (this.RecommendedReadershipTitleElementErrorMessageElement != null)
            {
                this.RecommendedReadershipTitleErrorMessage = this.RecommendedReadershipTitleElementErrorMessageElement.Text;
            }

            // ** Text Box Errors ** //

            if (this.CompletedReadershipElementErrorMessageElement != null)
            {
                this.CompletedReadershipErrorMessage = this.CompletedReadershipElementErrorMessageElement.Text;
            }

            if (this.DeletedReadershipElementErrorMessageElement != null)
            {
                this.DeletedReadershipErrorMessage = this.DeletedReadershipElementErrorMessageElement.Text;
            }

            if (this.ReadershipNotRequiredElementErrorMessageElement != null)
            {
                this.ReadershipNotRequiredErrorMessage = this.ReadershipNotRequiredElementErrorMessageElement.Text;
            }

            if (this.OverdueReadershipElementErrorMessageElement != null)
            {
                this.OverdueReadershipErrorMessage = this.OverdueReadershipElementErrorMessageElement.Text;
            }

            if (this.RecommendedReadershipElementErrorMessageElement != null)
            {
                this.RecommendedReadershipErrorMessage = this.RecommendedReadershipElementErrorMessageElement.Text;
            }

            if (this.RequiredReadershipElementErrorMessageElement != null)
            {
                this.RequiredReadershipErrorMessage = this.RequiredReadershipElementErrorMessageElement.Text;
            }

            if (this.PositiveReceiptTitleElementErrorMessageElement != null)
            {
                this.PositiveReceiptErrorMessage = this.PositiveReceiptTitleElementErrorMessageElement.Text;
            }

            if (this.NegativeReceiptTitleElementErrorMessageElement != null)
            {
                this.NegativeReceiptErrorMessage = this.NegativeReceiptTitleElementErrorMessageElement.Text;
            }

            
        }

        #endregion

        //
    }
}